<template>
  <div>
    <!-- 待映左右滚动效果 -->

    <div>
      <div class="pra-title">近期最受期待</div>
      <div class="pra-wrap">
        <ul>
          <li v-for="item in daiying2" :key="item.id">
            <div class="item-img">
              <img :src="item.img" alt="item.nm" />
            </div>
            <div>{{ item.nm }}</div>
            <div class="date">{{ item.comingTitle | getdate }}</div>
            <div class="pra-wish">
              <span>{{ item.wish }}想看</span>
            </div>
          </li>
        </ul>
      </div>
      <div class="guodu"></div>
      <ul class="wait">
        <div v-for="(item, index) in daiying" :key="item.id">
          <div
            v-if="index == 0 || daiying[index - 1].rt !== item.rt"
            class="group-date"
          >
            {{ item.comingTitle }}
          </div>
          <li>
            <div class="item-img">
              <img :src="item.img" />
            </div>
            <div class="item-text">
              <div class="item-l">
                <div>
                  <span>{{ item.nm }}</span>
                </div>
                <div>
                  <span class="wish">{{ item.wish }}</span
                  >人想看
                </div>
                <div>{{ item.star }}</div>
                <div>{{ item.rt }}上映</div>
              </div>
              <div class="item-r">
                <div
                  class="btn"
                  :style="
                    item.showStateButton
                      ? { background: '#3C9FE6' }
                      : { background: '#faaf00' }
                  "
                >
                  {{ item.showStateButton ? "预售" : "想看" }}
                </div>
              </div>
            </div>
          </li>
        </div>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "Wait",
  data() {
    return {
      daiying2: [],
      daiying: [],
      movdate: "",
    };
  },
  filters: {
    getdate: function (value) {
      var str = value;
      var kg = str.indexOf(" ");
      return str.substring(0, kg);
    },
  },
  mounted() {
    axios.get("./json/daiying.json").then((res) => {
      this.daiying = res.data.coming;
      console.log(this.daiying);
    });
    axios.get("./json/daiying2.json").then((res) => {
      this.daiying2 = res.data.coming;
      console.log(this.daiying2);
      this.daiying2.forEach((item) => {
        item.img = item.img.replace("w.h", "85.115");
      });
    });
  },
};
</script>

<style lang="less" scoped>
&::-webkit-scrollbar {
  display: none;
}
.pra-title {
  font-size: 14px;
  height: 40px;
  line-height: 40px;
  padding-left: 10px;
  color: #333;
}
.guodu {
  background: #f5f5f5;
  height: 8px;
  width: 100%;
}
.pra-wrap {
  width: 95%;
  margin: auto;
  overflow-x: scroll;
  ul {
    width: 1100px;
    display: flex;

    li {
      margin-right: 10px;
      width: 2.2667rem;
      height: 175px;
      position: relative;
      .pra-wish {
        position: absolute;
        padding-left: 4px;
        top: 98px;
        left: 0;
        color: #faaf00;
        font-size: 13px;
        font-weight: 600;
      }
      div {
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-weight: bold;
        font-size: 13px;
      }
      .date {
        color: #999;
        font-weight: normal;
        padding-top: 4px;
      }
      img {
        width: 2.2667rem;
        height: 3.0667rem;
      }
    }
  }
}
.wait {
  padding-bottom: 30px;
  .group-date {
    font-size: 14px;
    padding-left: 10px;
  }
  li:last-child {
    .item-text {
      border-bottom: none;
    }
  }
  li {
    display: flex;
    justify-content: space-around;
    padding: 5px;
    .item-img {
      width: 20%;

      img {
        width: 1.7067rem;
        height: 2.4rem;
        display: inline-block;
        // padding-left: 0.2667rem;
      }
    }
    .item-text {
      width: 75%;
      border-bottom: 1px solid #ccc;
      display: flex;
      justify-content: space-between;
      .item-l {
        font-size: 13px;
        color: #666;
        margin-bottom: 14px;
        width: 75%;
        div {
          margin-bottom: 5px;
          margin-top: 5px;
          .wish {
            font-size: 16px;
            color: #faaf00;
          }
        }
        div:nth-child(1) {
          font-size: 17px;
          font-weight: bold;
          color: #333;
          display: flex;
          align-items: center;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          img {
            width: 1.1467rem;
            height: 0.3733rem;
            margin-left: 5px;
          }
        }
        div:nth-of-type(3) {
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
        }
        .score {
          color: #faaf00;
          font-size: 15px;
          font-weight: bold;
        }
      }
      .item-r {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 20%;
        .btn {
          width: 1.44rem;
          height: 0.7467rem;
          border-radius: 1.0667rem;
          background-color: #f03d37;
          box-shadow: 0 0.04rem 0.04rem 0 rgb(240 61 55 / 15%);
          color: #fff;
          font-size: 13px;
          text-align: center;
          line-height: 0.7467rem;
        }
      }
    }
  }
}
</style>